package com.sx.entity.user;

import com.alibaba.fastjson.annotation.JSONField;
import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import com.sx.basic.BasicEntity;
import com.sx.basic.serializer.BigDecimalToStringSerializer;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;

import javax.persistence.*;
import java.math.BigDecimal;

/**
 * @author AdinZ
 * @date 2020/11/18 17:47
 */
@Data
@TableName(value = "sx_user_amount")
@Entity
@Table(name = "sx_user_amount")
@ApiModel(value = "用户金额表",description = "用户金额表")
public class AmountEntity extends BasicEntity {

    @Id
    @GeneratedValue
    @TableId(type = IdType.ASSIGN_ID)
    private Long id;

    @ApiModelProperty("用户id")
    private long uid;

    @ApiModelProperty("账户金额类型")
    @Enumerated(EnumType.STRING)
    private AmountType type;

    @ApiModelProperty("金额表创建时间")
    private long created=System.currentTimeMillis();

    @ApiModelProperty("最新更新时间")
    private long updated=System.currentTimeMillis();

    @ApiModelProperty("金额交易前")@Column(columnDefinition = "decimal(18,4)")
    @JSONField(serializeUsing = BigDecimalToStringSerializer.class)
    private BigDecimal beforeAmount=BigDecimal.ZERO;

    @ApiModelProperty("金额")@Column(columnDefinition = "decimal(18,4)")
    @JSONField(serializeUsing = BigDecimalToStringSerializer.class)
    private BigDecimal amount=BigDecimal.ZERO;

    @ApiModelProperty("行锁")
    @Version
    @com.baomidou.mybatisplus.annotation.Version
    private int version;

    /**
     * 金额类型,
     * 账户多种类型时可以自行添加枚举
     */
    public enum AmountType{
        MONEY
    }


}
